<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/inc/css.inc"%>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<title>我是医生</title>
		<link rel="stylesheet" href="${css}/amazeui.doctorin.css" />
		<link rel="stylesheet" href="${css}/validate.css" />
		<link rel="stylesheet" href="${css}/doctorin.css" />
		<script src="${js}/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript" src="${js}/amazeui.doctorin.js" ></script>
	</head>
	<script type="text/javascript">
		$(function(){
			var cookieVal = localStorage.doctorid;  //获取 local storage 
			if( typeof (cookieVal)  ==  "undefined" || cookieVal ==  undefined){
				$("#logindiv").show();
			}else{
				window.location.href = "<%=basePath%>/doctorSelectSyllabs.action?doctorId="+cookieVal;
			}
		});
	</script>
	<body id="logindiv" style="display:none">
		<div class="box">
			<img width="40%" style="margin-bottom: 50px;" src="${img}/logo.png">
			<form id="form1">
				<div class="questionitem">
					<input id="mobile" class="am-form-field am-input-sm" type="text" data-validate="mobile" data-describedby="mobile-description" placeholder="请输入您的手机号">
				</div>
				<button type="button" class="am-btn am-btn-primary am-radius">登录</button>
			</form>	
		</div>
		<script type="text/javascript" src="${js}/jquery-mvalidate.js" ></script>
		<script>
			
			$("button").click(function(){
				$("#form1").submit();
			});
		
			$.mvalidateExtend({
	            mobile:{
	            	required : true,   
	                pattern : /^0?1[3|4|5|7|8][0-9]\d{8}$/,
	                each:function(){
	                   
	                },
	                descriptions:{
	                    required : '<div class="field-invalidmsg">请输入您的手机号码</div>',
	                    pattern : '<div class="field-invalidmsg">您输入的手机号码格式不正确</div>'
	                }
	            },
	        });
	        $("#form1").mvalidate({
	            type:1,
	            onKeyup:true,
	            sendForm:true,
	            firstInvalidFocus:false,
	            valid:function(event,options){
	                //点击提交按钮时,表单通过验证触发函数
	                doctorPost();
	                event.preventDefault();
	            },
	            invalid:function(event, status, options){
	                //点击提交按钮时,表单未通过验证触发函数
	                
	            },
	            eachField:function(event,status,options){
	                //点击提交按钮时,表单每个输入域触发这个函数 this 执向当前表单输入域，是jquery对象
	            },
	            eachValidField:function(val){},
	            eachInvalidField:function(event, status, options){},
	            conditional:{               
	            },
	            descriptions:{
	                
	            }
	        });
	        
	        function doctorPost() {
		        var mobile = $("#mobile").val();
		        $.ajax({
		        	type:"post",
		        	url:"<%=basePath%>loginDoctor.action",
		        	async:false,
		   			data:{mobile:mobile},
		   			success: function(v){
		   				if(v.type == 200){
		   					localStorage.doctorid = v.content.id;
							window.location.href = "<%=basePath%>/doctorSelectSyllabs.action?doctorId=" + v.content.id;
		   				}else{
		   					alert("您的账号未注册！");
		   				}
		   			}
		        });
			}
		</script>
	</body>
</html>
